<template>

    <el-button type="primary" @click="handleLogin">测试登录</el-button>
    <el-button type="success" @click="handleUserList">测试获取用户信息列表</el-button>

</template>

<script setup>
import {
  Check,
  Delete,
  Edit,
  Message,
  Search,
  Star,
} from '@element-plus/icons-vue'

import requestUtil from '@/utils/request'

// 获取用户数据
const handleLogin = async()=> {
  let result = await requestUtil.get('user/jwt_test')
  let data = result.data
  if (data.code === '200') {
    //   请求成功
    const token = data.token
    console.log('登录成功!', 'token=' + token)
    // 将获取到的token存储到sessionStorage中
    window.sessionStorage.setItem('token', token)
  } else {
    console.log('登录失败')
  }
}
const handleUserList = async()=>{
    let result = await requestUtil.get('user/test')
    let data = result.data
    if(data.code === '200'){
        const userList = data.data
        console.log('用户信息列表:'+userList)
    }else {
      console.log('获取用户信息列表出错')
    }
}


</script>

